namespace RuoVea.OmiApi.Reports.Dto;

/// <summary>
/// 类型参数
/// </summary>
public class PageResultDto 
{
    /// <summary>
    /// 页码
    /// </summary>
    public int PageNo { get; set; }

    /// <summary>
    /// 分页大小
    /// </summary>
    public int PageSize { get; set; }

    /// <summary>
    /// 共多少页
    /// </summary>
    public int TotalPage
    {
        get
        {
            if (TotalRows > 0)
            {
                if (TotalRows % PageSize != 0)
                {
                    return TotalRows / PageSize + 1;
                }

                return TotalRows / PageSize;
            }

            return 0;
        }
        set { }
    }

    /// <summary>
    /// 总共多少行数据
    /// </summary>
    public int TotalRows { get; set; }

    /// <summary>
    /// 数据行
    /// </summary>
    public object Rows { get; set; }

    /// <summary>
    /// 初始化参数
    /// </summary>
    /// <param name="pageNo"></param>
    /// <param name="pageSize"></param>
    public PageResultDto(int pageNo, int pageSize)
    {
        PageNo = pageNo;
        PageSize = pageSize;
    }

    /// <summary>
    /// 初始化参数
    /// </summary>
    /// <param name="rows"></param>
    /// <param name="pageNo"></param>
    /// <param name="pageSize"></param>
    /// <param name="totalRows"></param>
    public PageResultDto(object rows, int pageNo, int pageSize, int totalRows)
    {
        Rows = rows;
        PageNo = pageNo;
        PageSize = pageSize;
        TotalRows = totalRows;
    }
}